Skip to main content

Advanced Steps

The combination of basic and routing steps will be enough to accomplish many processes you would want to build with UniFi. However, there are also some additional advanced steps that give you some more flexibility, including the ability to interact with other applications via their API's.

Send an HTTP Request

This sends a request to a 3rd party system for data. This could be an API, data feed, or indeed any service that will respond to an HTTP request. Typically the other system would respond with either the data requested, or if the request was to update data on the 3rd party system, a response as to whether that request was successful or not.

The following fields are required for an HTTP request:

  • Url - The full Url of the system you are sending the request to, e.g. http://www.floatrates.com/daily/gbp.json (this is the data feed for a currency exchange rates provider).
  • Method - The method of request that the 3rd party system requires, typically this will be GET for data requests and POST for sending data, but other methods are possible. Documentation for the 3rd party system should make it clear what is required here.
  • Content - This is the body of the request. Depending on the request type, this is not always required but if you are wanting to update data on another system then here is where you would give it that information. If you have already done a 'get current record' step (as documented in the 'routing steps' section) then you can use the Javascript CurrentRecord.Result to send all fields in the JSON format. You can use JSON.parse(CurrentRecord.Result).field_id to get the data held in individual fields, combined with other Javascript for formatting purposes if required.
  • Content Type - This will be defined by what the 3rd party software requires.
  • Authorisation - What authorisation header, if any, is required by the software you are sending the request to. Typically this may be an API key or some other unique security reference.
  • Request Headers - Any other headers that your request requires, again this will be specified by the software you are communicating with. These should be entered in the format 'Header: Value' with one set per line.
  • Read Content - This means the process will wait for a response and then write that response back to the transaction. Ensure this is ticked if you want to use the response in a later stage of the process.
  • Supported Status Codes - Part of the standard response to a request of this type is the status code. These can indicate a success (code 200) or various types of failure. However, depending on the type of web request other codes in the 200 range may indicate that your request worked as intended. Enter here a comma-separated list of the codes you want to cater for and a separate branch of the process will then be possible for each code as well as an additional 'unsupported response code' option if an unexpected response is received.
tip

Don't use spaces or special characters in the name if you want to use the response in a further step, like setting a value.

Data Connector

Sometimes when interacting with other application you need more control over what you are sending than a 'Send HTTP' request can provide. In this case you can create a 'Data Connector' and then call that data connector as a step in the process. See the section on data connectors for more information on how these can be used.

Set Value

This allows you to set the value of a field on the form. There are several circumstances in which you might want to do this:

Set Value with a Literal value

You can use this to simply update a field with a literal value (e.g. set a 'Status' field depending on how a process is progressing). You can do this by selecting the column and then entering the value you want to update it with.

Set Value with the contents of another cell

This may be required to preserve a value at this stage of the process that is liable to later be changed. For this you can use the same Javascript format for the 'Send HTTP' step, i.e. JSON.parse(CurrentRecord.Result).field_id having first obtained the CurrentRecord in a 'Get Current Record' step.

Set Value with the response to an HTTP request

This will often be in response to an HTTP request, where you want to write back a success/failure message or some other response information such as a reference number. To use the body of a JSON response (a common way of receiving back JSON requests) you can use the following Javascript in the value box:

JSON.parse(`${sendingstepname.ResponseContent}`).json_field_name

So if the sending step name was 'SendToSun' and the JSON response included the pair "journal_number":"12345", then the formula would be:

JSON.parse(`${SendToSun.ResponseContent}`).journal_number

tip

Note the use of the ` backtick character here instead of the usual quote marks.

Set Variable

A variable is a text name representing a value that may be used later in the process. You may wish to use these where the same value is being referred to multiple times within a process or where it makes it easier to understand what is going on in steps that use this process. The variable can be literal (i.e. just a value) or set by a Javascript formula, in which case you can use any of the examples above as well as any additional code you require.

Set Status

This allows you to set a free-text status of the process, overwriting any system-generated status. This may make progress information more readable in more complex processes.

Set Exception

This can be used to indicate that an error has occurred in the process. It could be used in conjunction with a 'Send HTTP' step to deal with unexpected responses to indicate to the user that something has gone wrong with the request.